Use meson features to simplify dependency checking
authorJonathan Dieter <jdieter@gmail.com>
Sun, 9 Jan 2022 19:49:28 +0000 (19:49 +0000)
committerJonathan Dieter <jdieter@gmail.com>
Sun, 9 Jan 2022 20:58:56 +0000 (20:58 +0000)
Signed-off-by: Jonathan Dieter <jdieter@gmail.com>
.gitignore
meson.build
meson_options.txt
subprojects/zstd.wrap

index 726557440e5031e2e71849e6253826945aa98fc5..41352f3a7f52b29e26ef10f94f0569f870f43ca7 100644 (file)
@@ -1,4 +1,6 @@
 cov-int
 /build
+/subprojects/packagecache
+/subprojects/zstd-*
 test/abi/new
 test/abi/stable/ABI.dump
index ced42338fd5cb7dc6e9ddfbfa7486ebf91164578..453e5fbe473402b698d54c7a02d5b753e16356b5 100644 (file)
@@ -18,20 +18,17 @@ if build_machine.system() == 'freebsd'
     add_project_arguments('-DFREEBSD', language : 'c')
 endif
 
-if get_option('with-zstd') == 'disabled'
-    zstd_dep = dependency('', required : false)
+
+if build_machine.system() == 'windows'
+    zstd_dep = dependency('zstd', modules: 'zstd::libzstd_shared', required : get_option('with-zstd'), fallback: 'zstd')
 else
-    if build_machine.system() == 'windows'
-        zstd_dep = dependency('zstd', modules: 'zstd::libzstd_shared', required : get_option('with-zstd') == 'enabled')
-    else
-        zstd_dep = dependency('libzstd', required : get_option('with-zstd') == 'enabled',
-                              default_options: ['bin_programs=false', 'zlib=disabled', 'lzma=disabled', 'lz4=disabled'])
-    endif
-    if zstd_dep.found()
-        add_project_arguments('-DZCHUNK_ZSTD', language : 'c')
-        if zstd_dep.version().version_compare('<=1.4.9')
-            add_project_arguments('-DOLD_ZSTD', language : 'c')
-        endif
+    zstd_dep = dependency('libzstd', required : get_option('with-zstd'), fallback: 'zstd',
+                          default_options: ['bin_programs=false', 'zlib=disabled', 'lzma=disabled', 'lz4=disabled'])
+endif
+if zstd_dep.found()
+    add_project_arguments('-DZCHUNK_ZSTD', language : 'c')
+    if zstd_dep.version().version_compare('<=1.4.9')
+        add_project_arguments('-DOLD_ZSTD', language : 'c')
     endif
 endif
 
@@ -41,17 +38,14 @@ else
     curl_dep = dependency('libcurl')
 endif
 
-if get_option('with-openssl') == 'disabled'
-    openssl_dep = dependency('', required : false)
+
+if build_machine.system() == 'windows'
+    openssl_dep = dependency('openssl', modules : ['OpenSSL::SSL', 'OpenSSL::Crypto'], required : get_option('with-openssl'))
 else
-    if build_machine.system() == 'windows'
-        openssl_dep = dependency('openssl', modules : ['OpenSSL::SSL', 'OpenSSL::Crypto'], required : get_option('with-openssl') == 'enabled')
-    else
-        openssl_dep = dependency('openssl', required : get_option('with-openssl') == 'enabled')
-    endif
-    if openssl_dep.found()
-        add_project_arguments('-DZCHUNK_OPENSSL', language : 'c')
-    endif
+    openssl_dep = dependency('openssl', required : get_option('with-openssl'))
+endif
+if openssl_dep.found()
+    add_project_arguments('-DZCHUNK_OPENSSL', language : 'c')
 endif
 
 inc = []
index 7dc221e4faecdd5434c4b6db53e67f962a2fa476..bb7dd6c251a851b5ba4f4d662a3d88c1ec2126b6 100644 (file)
@@ -1,3 +1,3 @@
-option('with-zstd', type : 'combo', choices : ['enabled', 'disabled', 'auto'], value : 'auto')
-option('with-openssl', type : 'combo', choices : ['enabled', 'disabled', 'auto'], value : 'auto')
+option('with-zstd', type : 'feature', value : 'auto')
+option('with-openssl', type : 'feature', value : 'auto')
 option('coverity', type : 'boolean', value : false)
index 60791f74c311835cec4b32fd96d26972ccb9af03..68691f829ca21fd55b066d9ef40aee13e169f716 100644 (file)
@@ -8,4 +8,4 @@ patch_filename = zstd-1.4.5-1-wrap.zip
 patch_hash = fd9cb7b9c8f7092ef1597ff68f170beef65fcf33e575a621955cf405a41db1cc
 
 [provide]
-zstd = zstd_dep
+libzstd = libzstd_dep